#!/usr/bin/env python
import numpy.numarray as na

from pylab import *

teste = sys.argv[1]
basename = sys.argv[2]

test_file = open(teste)

data = []
selc_carac = []
num_form = []

for line in test_file:

	data.append(float(line.rsplit(' ')[0]))
	selc_carac.append(line.rsplit(' ')[1])

num_form.append(1.0 + float(selc_carac[0]) * 0.75)
num_form.append(1.0 + float(selc_carac[0]) * 1.5)

labels = ["Original\n Selec: " + selc_carac[0], str(int(num_form[0])) + " Formigas\nS/ Busca Local\n Selec: " + selc_carac[1], str(int(num_form[0])) + " Formigas\nC/ Busca Local\n Selec: " + selc_carac[2], str(int(num_form[1])) + " Formigas\nS/ Busca Local\n Selec: " + selc_carac[3], str(int(num_form[1])) + " Formigas\nC/ Busca Local\n Selec: " + selc_carac[4]]

#data =   [3.75 , 4.75, 2.3, 5.6, 4.2]
#error =  [0.3497, 0.3108, 0.3111, 0.3290, 0.3223]

xlocations = na.array(range(len(data))) + 0.5

width = 0.5
#bar(xlocations, data, yerr=error, width=width)
bar(xlocations, data, width=width)


#yticks(range(0, 8))
xticks(xlocations+ width/2, labels)

xlim(0, xlocations[-1]+width*2)

title(basename)

gca().get_xaxis().tick_bottom()
gca().get_yaxis().tick_left()

savefig('graficos/' + basename)

show()